package avicit.bdp.oss.utils.upload.entity;

import avicit.bdp.oss.utils.upload.utils.common.TaskStatusEnum;
import avicit.bdp.oss.utils.upload.utils.common.TaskTypeEnum;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-12-09
 * @类说明：TaskInfoDto
 * @修改记录：
 * @注意事项：
 * @主要功能：OSS对象存储任务管理模块，任务内容
 */
public class TaskInfoDto {
    /**
     * 任务ID,UUID
     */
    private String id;

    /**
     * 用户ID
     */
    private String userId;

    /**
     * 桶名称
     */
    private String bucketName;

    /**
     * 前缀
     */
    private String prefix;

    /**
     * 对象名称
     */
    private String objectName;

    /**
     * 对象大小
     */
    private long objectSize;

    /**
     * 分片数量
     */
    private int chunks;

    /**
     * 任务类型，包括上传、下载等
     */
    private TaskTypeEnum type;

    /**
     * 任务状态，包括状态、进度
     */
    private TaskStatus status;

    /**
     * 无参构造函数
     */
    public TaskInfoDto() {
    }

    /**
     * 有参构造函数
     * @param taskInfoDto
     */
    public TaskInfoDto(TaskInfoDto taskInfoDto) {
        this.id = taskInfoDto.id;
        this.userId = taskInfoDto.userId;
        this.bucketName = taskInfoDto.bucketName;
        this.prefix = taskInfoDto.prefix;
        this.objectName = taskInfoDto.objectName;
        this.objectSize = taskInfoDto.objectSize;
        this.chunks = taskInfoDto.chunks;
        this.type = taskInfoDto.type;
        this.status = taskInfoDto.status;
    }

    /**
     * 有参构造函数
     * @param id
     * @param userId
     * @param bucketName
     * @param prefix
     * @param objectName
     * @param objectSize
     * @param type
     * @param status
     */
    public TaskInfoDto(String id, String userId, String bucketName, String prefix, String objectName, long objectSize,
                       int chunks, TaskTypeEnum type, TaskStatus status) {
        this.id = id;
        this.userId = userId;
        this.bucketName = bucketName;
        this.prefix = prefix;
        this.objectName = objectName;
        this.objectSize = objectSize;
        this.chunks = chunks;
        this.type = type;
        this.status = status;
    }

    public String getId() {
        return id;
    }

    public String getUserId() {
        return userId;
    }

    public String getBucketName() {
        return bucketName;
    }

    public String getPrefix() {
        return prefix;
    }

    public String getObjectName() {
        return objectName;
    }

    public long getObjectSize() {
        return objectSize;
    }

    public int getChunks() {
        return chunks;
    }

    public TaskTypeEnum getType() {
        return type;
    }

    public TaskStatus getStatus() {
        return status;
    }

    public void setStatus(TaskStatus status) {
        this.status = status;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public void setObjectName(String objectName) {
        this.objectName = objectName;
    }

    public void setObjectSize(long objectSize) {
        this.objectSize = objectSize;
    }

    public void setChunks(int chunks) {
        this.chunks = chunks;
    }

    public void setType(TaskTypeEnum type) {
        this.type = type;
    }

    public static class TaskStatus {
        private TaskStatusEnum status;

        private String progress;

        public TaskStatus() {
        }

        public TaskStatus(TaskStatusEnum status, String progress) {
            this.status = status;
            this.progress = progress;
        }

        public TaskStatusEnum getStatus() {
            return status;
        }

        public String getProgress() {
            return progress;
        }

        public void setStatus(TaskStatusEnum status) {
            this.status = status;
        }

        public void setProgress(String progress) {
            this.progress = progress;
        }
    }

    public static TaskInfoDto.Builder builder() {
        return new TaskInfoDto.Builder();
    }

    public static final class Builder {
        private String id;
        private String userId;
        private String bucketName;
        private String prefix;
        private String objectName;
        private long objectSize;
        private int chunks;
        private TaskTypeEnum type;
        private TaskStatus status;

        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder userId(String userId) {
            this.userId = userId;
            return this;
        }

        public Builder bucketName(String bucketName) {
            this.bucketName = bucketName;
            return this;
        }

        public Builder prefix(String prefix) {
            this.prefix = prefix;
            return this;
        }

        public Builder objectName(String objectName) {
            this.objectName = objectName;
            return this;
        }

        public Builder objectSize(long objectSize) {
            this.objectSize = objectSize;
            return this;
        }

        public Builder chunks(int chunks) {
            this.chunks = chunks;
            return this;
        }

        public Builder type(TaskTypeEnum type) {
            this.type = type;
            return this;
        }

        public Builder status(TaskStatus status) {
            this.status = status;
            return this;
        }

        public TaskInfoDto build() {
            return new TaskInfoDto(id, userId, bucketName, prefix, objectName, objectSize, chunks, type, status);
        }
    }
}
